import request from "@/utils/request";
import qs from "qs";
export default {
  //分页获取品牌列表 (get请求只能用params:{}来传递参数)
  listAll() {
    return request({
      url: "/api-goods/spu/brands/available/all",
      method: "get"
    });
  },
  //分页获取品牌列表 (get请求只能用params:{}来传递参数)
  count() {
    return request({
      url: "/api-goods/spu/count",
      method: "get"
    });
  },
  //分页获取品牌列表 (get请求只能用params:{}来传递参数)
  pageList(pageNum, pageSize, sort) {
    return request({
      url: "/api-goods/spu/brands",
      method: "get",
      params: { pageNum, pageSize, sort }
    });
  },
  //分页条件查询列表 (get请求只能用params:{}来传递参数)
  pageMatchList(match) {
    var data = qs.stringify(match);
    return request({
      url: `/api-goods/spu/pageList/match`,
      method: "post",
      data
    });
  },

  // 通过条件分页获取商品SPU数据(商品回收站)

  pageMatchRecycle(match) {
    var data = qs.stringify(match);
    return request({
      url: `/api-goods/spu/pageList/matchRecycle`,
      method: "post",
      data
    });
  },

  //分页获取品牌列表 (get请求只能用params:{}来传递参数)
  getOne(id) {
    return request({
      url: `/api-goods/spu/getSpu/${id}`,
      method: "get"
    });
  },
  //根据id删除数据
  deleteById(id) {
    return request({
      url: `/api-goods/spu/deleteSpu/${id}`,
      method: "delete"
    });
  },

  //根据id删除数据(物理删除)
  deleteEn(id) {
    return request({
      url: `/api-goods/spu/deleteSpuTwo/${id}`,
      method: "delete"
    });
  },
  //根据id修改数据
  updateById(spu) {
    var data = qs.stringify(spu);
    return request({
      url: "/api-goods/spu/updateSpu",
      method: "put",
      data
    });
  },
  // 添加品牌
  add(formData) {
    var data = qs.stringify(formData);
    return request({
      url: "/api-goods/spu/addSpu",
      method: "post",
      data
    });
  },
  //根据id删除数据
  deleteImage(imgName, spuId) {
    return request({
      url: `/api-goods/spu/deleteImage`,
      method: "delete",
      params: { imgName, spuId }
    });
  },
  
  // 根据名称获取到数据(模糊查询)
  getByName(name){
    return request({
      url: `/api-goods/spu/getByName`,
      method: "get",
      params: {name}
    });

  },

  // 根据名称获取到数据(精准查询)
  getByNameT(name){
    return request({
      url: `/api-goods/spu/getByNameT`,
      method: "get",
      params: {name}
    });

  },

  // 根据分类ID获取数据
  getSpuByCategoryId(categoryId){
    return request({
      url: `/api-goods/spu/getSpuByCategoryId`,
      method: "get",
      params: {categoryId}
    });

  },

};
